package restaurant;

/**
 * The Class cmdActivateTable.
 * 
 * @author Ebonie
 */

public class cmdActivateTable implements Command
{

	/** The info. */
	private InformationAggregator info;

	/** The table no. */
	private int tableNo;

	/** The pin. */
	private int pin;



	/**
	 * Instantiates a new cmd activate table.
	 * 
	 * @param info the info
	 * @param tableNo the table no
	 * @param pin the pin
	 */
	public cmdActivateTable(InformationAggregator info, int tableNo, int pin) {
		this.info = info;
		this.tableNo = tableNo;
		this.pin = pin;
	}



	/**
	 * Execute.
	 * 
	 * @return the object
	 * @see restaurant.Command#execute()
	 */
	@Override
	public Object execute()
	{
		Tables tables = info.getTables();
		int tablePin = tables.getTablePin(tableNo);
		boolean successful;

		if (tablePin == pin) {
			tables.activateTable(tableNo);
			successful = true;
		}
		else
			successful = false;

		CustomerTabs tabs = info.getTabs();
		tabs.createTab(tableNo);

		return successful;
	}
}
